<template>
  <div style="width: 1000px">
    <el-radio-group v-model="labelPosition" size="small">
      <el-radio-button label="left">左对齐</el-radio-button>
      <el-radio-button label="right">右对齐</el-radio-button>
      <el-radio-button label="top">顶部对齐</el-radio-button>
    </el-radio-group>

    <div style="margin: 20px;"></div>
    <el-form :label-position="labelPosition" label-width="80px" :model="article">
      <el-form-item label="文章编号">
        <el-input v-model="article.articleId" readonly></el-input>
      </el-form-item>
      <el-form-item label="文章标题">
        <el-input v-model="article.articleTitle"></el-input>
      </el-form-item>
      <el-form-item label="创建人">
        <el-input v-model="article.teacherName"></el-input>
      </el-form-item>
      <el-form-item label="创建时间">
        <el-input v-model="article.crateTime" readonly></el-input>
      </el-form-item>
      <el-form-item label="文章内容">
        <el-input v-model="article.articleContent"></el-input>
      </el-form-item>
    </el-form>
    <el-button  @click="saveArticle();turnPage(articleId,'list')">确认提交</el-button>
    <el-button  @click="turnPage(articleId,'list')">返回</el-button>
  </div>
</template>


<script>
  import {SystemManageService} from '../SystemManageService'
  import managerNavigation from '../../../components/systemManage/ManageNavigation'
  import managerHeader from '../../../components/systemManage/ManageHeader'
  import manageContainer from '../../../components/systemManage/ManageContainer'
  import router from '../../../router'

  export default {
    name: "EditArticle",
    components: {
      managerNavigation: managerNavigation,
      managerHeader: managerHeader,
      manageContainer: manageContainer,
    },
    data() {
      return {
        labelPosition: 'right',
        article: {},
      }
    },
    props:{
      articleId:''
    },
    created: function () {
      this.findArticleById(this.articleId);
    },
    methods: {
      findArticleById(articleId) {
        SystemManageService.findArticleById(articleId).then(res => {
          this.article = res.data;
        })
      },
      saveArticle() {
        console.log(this.article);
        SystemManageService.saveArticle(this.article).then(res => {
        });
      },
      turnPage(articleId,type){
        this.$emit('turnPage',articleId,type)
      }
    }
  }

</script>

<style scoped>
  .content {
    display: flex;
    justify-content: space-between;
  }
</style>
